<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	//////-------------login-----------
	public function login()
	{
		$this->load->view('admin/admin_home');
	}


	public function logout()
	{
		$this->load->library('session');

		$array_items = array('username' => '', 'logged_in' => '');
		$this->session->unset_userdata($array_items);
		$displayData['errorMsg'] = 'You have been successfully logged out.';
		$this->load->view('admin/admin_home', $displayData);
	}


	public function loginNow()
	{
		//print_r($_GET);
		$this->load->model('adminmodel');
		$this->load->library('session');

		$username=$this->adminmodel->authenticate($_POST);
		//var_dump($username);
		if (isset($username[0]['admin_username']) && $_POST['username']==$username[0]['admin_username']){
			$newdata = array(
					'admin_id'  => $username[0]['admin_id'],
					'username'  => $username[0]['admin_username'],
					'work_type'  => $username[0]['work_type'],
					'logged_in' => TRUE
			);
			$this->session->set_userdata($newdata);
			$sessionUserData = $this->session->all_userdata();
		}else {
			$array_items = array('admin_id' => '', 'username' => '', 'work_type' => '', 'logged_in' => '');
			$this->session->unset_userdata($array_items);
		}
		$pTabSelection="";
		$displayData['pTabSelection']=$pTabSelection;
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			//var_dump($allVerifyCount);
			//print_r($_GET);
			$displayData['sessionUserData']=$sessionUserData;
			$this->load->view('admin/welcome', $displayData);
		}else {
			$displayData['errorMsg'] = 'Please enter correct Username/Password.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}
	////////////----------------------login end-----------------------

	////////////---------------------change Password-------------------------------------------->
	public function changePassword()
	{

		$this->load->model('adminmodel');
		$this->load->library('session');

		$pTabSelection="";
		$displayData['pTabSelection']=$pTabSelection;
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$adminId = $this->session->userdata('admin_id');
			$userpass = $this->adminmodel->getAdminPass($adminId);
			$displayData['userpass'] = $userpass;


			$this->load->view('admin/changePassword', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}



	}
	public function updatePass()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			if(trim($_POST['old_pass1'])==trim($_POST['oldpass'])){
				//$allVerifyCount = $this->adminmodel->validateCount();
				//$displayData['allVerifyCount'] = $allVerifyCount;
				$adminId = $this->session->userdata('admin_id');
				$this->adminmodel->updateChangePass($_POST, $adminId);
				$userpass = $this->adminmodel->getAdminPass($adminId);
				$displayData['userpass'] = $userpass;

				$this->load->view('admin/changePassword', $displayData);
			}else{
				$adminId = $this->session->userdata('admin_id');
				$userpass = $this->adminmodel->getAdminPass($adminId);
				$displayData['userpass'] = $userpass;
				$displayData['changeError'] = 'Old Password did not matched.';
				$this->load->view('admin/changePassword', $displayData);
				//var_dump($adminId);
			}
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}


	/////////////// category Managment-------------------------------------------------------->

	public function category()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			$this->load->view('admin/category',$displayData);

		}
		else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home',  $displayData);
		}
	}
	public function deleteCategory($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->deleteCategoryById($cId);
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			$this->load->view('admin/category',$displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}
	public function editCategory($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$catName = $this->adminmodel->getCategoryById($cId);
			$displayData['catName'] = $catName;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/edit_category',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function updateCategory()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->categoryUpdate($_POST);
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/category', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function addCategory()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){

			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/addCategory');
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}

	}
	public function addCategoryForm()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->insertCategory($_POST);
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/category', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}
	public  function addTheme()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
			
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			//$this->adminmodel->insertCategory($_POST);
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/addtheme',$displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
			
			
	}
	public  function addNewTheme()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->insertTheme($_POST);
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			$theme= $this->adminmodel->manageTheme();
			$displayData['theme'] = $theme;

			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/managetheme',$displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}


	}
	public function manageTheme()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$theme= $this->adminmodel->manageTheme();
			$displayData['theme'] = $theme;
			$this->load->view('admin/managetheme',$displayData);

		}
		else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home',  $displayData);
		}
	}
	public function deletetheme($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->deleteThemeById($cId);
			$theme= $this->adminmodel->manageTheme();
			$displayData['theme'] = $theme;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;

			$this->load->view('admin/managetheme',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function editTheme($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$category = $this->adminmodel->editCategory();
			$themeName = $this->adminmodel->getthemeById($cId);
			//print_r($themeName);
			//die();
			$displayData['themeName'] = $themeName;
			$displayData['categoryName'] = $category;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/edit_theme',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function updateTheme()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->themeUpdate($_POST);
			$theme= $this->adminmodel->manageTheme();
			$displayData['theme'] = $theme;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/managetheme', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public  function addMedium()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			$theme= $this->adminmodel->manageTheme();
			$displayData['theme'] = $theme;

			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/addmedium',$displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}


	}


	public  function addNewMedium()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->insertMedium($_POST);
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			$theme= $this->adminmodel->manageTheme();
			$displayData['theme'] = $theme;
			$medium= $this->adminmodel->manageMedium();
			$displayData['medium'] = $medium;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/managemedium',$displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}

	public function loadTheme($catId)
	{
		$this->load->model('adminmodel');
		$theme= $this->adminmodel->selecThemeById($catId);
		$displayData['theme'] = $theme;
		$displayData['catId'] = $catId;
		$this->load->view('admin/common/theme_select',$displayData);
	}

	public function manageMedium()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$medium= $this->adminmodel->manageMedium();
			$displayData['medium'] = $medium;
			$this->load->view('admin/managemedium',$displayData);

		}
		else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home',  $displayData);
		}
	}
	public function deletemedium($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->deleteMediumById($cId);
			$medium= $this->adminmodel->manageMedium();
			$displayData['medium'] = $medium;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;

			$this->load->view('admin/managemedium',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function editMedium($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$category = $this->adminmodel->editCategory();
			$mediumName = $this->adminmodel->getmediumById($cId);
			$catId = $mediumName['cat_id'];
			$theme = $this->adminmodel->selecThemeById($catId);
			if(empty($theme)){
				$catId = $category[0]['cat_id'];
				$theme1 = $this->adminmodel->selecThemeById($catId);
			}
			$displayData['category'] = $category;
			$displayData['theme'] = $theme;
			$displayData['theme1'] = $theme1;
			$displayData['mediumName'] = $mediumName;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/edit_medium',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function updateMedium()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->mediumUpdate($_POST);
			$medium= $this->adminmodel->manageMedium();
			$displayData['medium'] = $medium;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/managemedium', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}


	//////////////// category managment end----------------------------------------------------------------	>
	///////////////  artist Managment ----------------------------------------------------------------------->

	public function addArtist()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->load->view('admin/addartist');
		}
		else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
			
			
	}
	public function add_newartistForm()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$_POST['file'] = $_FILES;
			$this->adminmodel->insertArtist($_POST);
			$artist= $this->adminmodel->manageArtist();
			$displayData['artist'] = $artist;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/manageartist',$displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}
	public function manage_artist()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$artist= $this->adminmodel->manageArtist();
			$displayData['artist'] = $artist;
			$this->load->view('admin/manageartist',$displayData);
		}
		else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}


	}

	public function deleteartist($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->deleteArtistById($cId);
			$artist= $this->adminmodel->manageArtist();
			$displayData['artist'] = $artist;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;

			$this->load->view('admin/manageartist',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function editartist($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$artisname = $this->adminmodel->getartistById($cId);
			$artisevent = $this->adminmodel->getartisteventById($cId);
			$artisaward = $this->adminmodel->getartistawardById($cId);
			$displayData['artisname'] = $artisname;
			$displayData['artisevent'] = $artisevent;
			$displayData['artisaward'] = $artisaward;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/edit_artist',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function updateartist()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
			
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$_POST['file'] = $_FILES;
			$this->adminmodel->artistUpdate($_POST);
			$this->adminmodel->artistEvent($_POST);
			$this->adminmodel->artistAwards($_POST);
			$artist= $this->adminmodel->manageArtist();
			$displayData['artist'] = $artist;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/manageartist', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	///////////////n artist maNAgment end--------------------------------------------------------------------->


	/////////////// Galery  maNAgment Start--------------------------------------------------------------------->
	public function addGallery()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$artist= $this->adminmodel->manageArtist();
			$displayData['artist'] = $artist;
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			$theme= $this->adminmodel->manageTheme();
			$displayData['theme'] = $theme;
			$medium= $this->adminmodel->manageMedium();
			$displayData['medium'] = $medium;

			$this->load->view('admin/addgallery',$displayData);
		}
		else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
			
			
	}
	public function addnewArtist()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->load->view('admin/addartist');
		}
		else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}


	}
	public function loadGTheme($catId)
	{
		$this->load->model('adminmodel');
		$theme= $this->adminmodel->selecThemeById($catId);
		$displayData['theme'] = $theme;
		$displayData['catId'] = $catId;
		$this->load->view('admin/common/theme_select',$displayData);
	}

	public function loadGmedium($catId)
	{
		$this->load->model('adminmodel');
		$medium= $this->adminmodel->selecmediumById($catId);
		$displayData['medium'] = $medium;
		$displayData['catId'] = $catId;
		$this->load->view('admin/common/medium_select',$displayData);
	}
	public function addGalleryForm()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$_POST['file'] = $_FILES;
			$this->adminmodel->insertGallery($_POST);
			$gallery= $this->adminmodel->manageGallery();
			$displayData['gallery'] = $gallery;
			$this->load->view('admin/managegallery',$displayData);
		}
		else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}


	}

	public function manageGallery()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$gallery= $this->adminmodel->manageGallery();
			$displayData['gallery'] = $gallery;
			//var_dump($gallery);
			$this->load->view('admin/managegallery',$displayData);
		}
		else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}


	}

	public function deleteGallery($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->deleteGalleryById($cId);
			$gallery= $this->adminmodel->manageGallery();
			$displayData['gallery'] = $gallery;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;

			$this->load->view('admin/managegallery',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function editGallery($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$galleryName = $this->adminmodel->getgallerytById($cId);
			$displayData['galleryName'] = $galleryName;
			$artist= $this->adminmodel->manageArtist();
			$displayData['artist'] = $artist;
			$mappingid= $this->adminmodel->getMappingid($cId);
			$displayData['mappingid'] = $mappingid;
			$category = $this->adminmodel->editCategory();
			$displayData['category'] = $category;
			$catId = $mappingid['cat_id'];
			$themeId = $mappingid['theme_id'];
			$theme= $this->adminmodel->selecThemeById($catId);
			$displayData['theme'] = $theme;
			$medium= $this->adminmodel->selecmediumById($themeId);
			$displayData['medium'] = $medium;
			//$artisaward = $this->adminmodel->getartistawardById($cId);

			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/edit_gallery',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}
	public function updateGallery()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$_POST['file'] = $_FILES;
			$this->adminmodel->galleryUpdate($_POST);
			$this->adminmodel->galleryUpdatemap($_POST);
			$gallery= $this->adminmodel->manageGallery();
			$displayData['gallery'] = $gallery;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/managegallery', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	/////////////// Galery  maNAgment End --------------------------------------------------------------------->
	/////////////// Customer Validation  ------------------------------------------------------------------------>
	public function customerValidation()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$user= $this->adminmodel->manageUser();
			$displayData['user'] = $user;
			//var_dump($user);
			$this->load->view('admin/customerValidation',$displayData);
		}
		else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}



	}

	public function deleteuser($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$this->adminmodel->deleteUserById($cId);
			$user= $this->adminmodel->manageUser();
			$displayData['user'] = $user;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;

			$this->load->view('admin/customerValidation',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function edituser($cId)
	{
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
			$userName = $this->adminmodel->getUserById($cId);
			$displayData['userName'] = $userName;
			//$allVerifyCount = $this->adminmodel->validateCount();
			// $displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/edituser',$displayData);
		}else
		{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function updateUser()
	{
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){

			$this->adminmodel->userUpdate($_POST);
			//   $this->adminmodel->userinsert($_POST);
			$user= $this->adminmodel->manageUser();
			$displayData['user'] = $user;
			//$allVerifyCount = $this->adminmodel->validateCount();
			//$displayData['allVerifyCount'] = $allVerifyCount;
			$this->load->view('admin/customerValidation', $displayData);
		}else{
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}
	/////////////// Customer Validation  End ------------------------------------------------------------------------>
	//*****************Manage Event Start***************\\
	public function addNewEvent() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {

			$this->load->view('admin/addNewEvent');
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function insertNewEvent() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {
			$event = $this->adminmodel->insertEvent($_POST);
			$displayData['event'] = $event;
			$allEvent = $this->adminmodel->managAllEvent();
			$displayData['allEvent'] = $allEvent;
			$displayData['msg'] = 'Data Inserted Succesfully';

			$this->load->view('admin/manageEvent', $displayData);
		} else {
	 			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
	 			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function manageEvent() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {

			$allEvent = $this->adminmodel->managAllEvent();
			$displayData['allEvent'] = $allEvent;
			//var_dump($displayData);
			$this->load->view('admin/manageEvent', $displayData);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function editEvent($eId) {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {
			$oneEvent = $this->adminmodel->getEventById($eId);
			$displayData['oneEvent'] = $oneEvent;
			$this->load->view('admin/editEvent', $displayData);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function updateEvent() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {
			$update = $this->adminmodel->updateEvent($_POST);
			$displayData['update'] = $update;
			$allEvent = $this->adminmodel->managAllEvent();
			$displayData['allEvent'] = $allEvent;

			$this->load->view('admin/manageEvent', $displayData);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	public function deleteEvent($eId) {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {
			$delete = $this->adminmodel->deleteEventById($eId);
			$displayData['delete'] = $delete;
			$allEvent = $this->adminmodel->managAllEvent();
			$displayData['allEvent'] = $allEvent;
			$this->load->view('admin/manageEvent', $displayData);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin_home', $displayData);
		}
	}

	//*****************Manage Event End***************\\
	//*********************Manage CMS Start********************************\\

	public function addCms() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {

			$this->load->view('admin/addCms');
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}

	public function insertCms() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {

			$addCms = $this->adminmodel->insertCms($_POST);
			$displayData['addCms'] = $addCms;
			$displayData['msg'] = 'CMS Inserted Succesfully';
			$allCms = $this->adminmodel->getAllCms();
			$displayData['allCms'] = $allCms;
			$this->load->view('admin/manageCms', $displayData);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}

	public function manageCms() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {

			$allCms = $this->adminmodel->getAllCms();
			$displayData['allCms'] = $allCms;
			$this->load->view('admin/manageCms', $displayData);
			//var_dump($allPage);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}

	public function editCms($aId) {
		$this->load->model('adminmodel');
		$this->load->library('session');

		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {
			$cmsDetail = $this->adminmodel->CmsDetailByID($aId);
			$displayData['cmsDetail'] = $cmsDetail;
			//var_dump($cmsDetail);
			$this->load->view('admin/editCms', $displayData);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}

	public function updateCms() {
		$this->load->model('adminmodel');
		$this->load->library('session');
		//var_dump($_POST);die();
		$sessionUserData = $this->session->all_userdata();
		if (isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']) {
			$allCms = $this->adminmodel->getAllCms();
			$displayData['allCms'] = $allCms;
			$updatCms = $this->adminmodel->updateCmsById($_POST);
			$displayData['updatCms'] = $updatCms;
			$displayData['msg'] = 'Update CMS Succesfully';
			$this->load->view('admin/manageCms', $displayData);
		} else {
			$displayData['errorMsg'] = 'Your session has been expired. Please relogin.';
			$this->load->view('admin/admin-home', $displayData);
		}
	}

	//*********************Manage CMS End********************************\\


}
